<template>
    <div class="person-xinxi">
        <h3 style="font-weight: 700;">{{ user.personName }}</h3>
        <template>
            <div v-if="user.personType === 0 && user.cardNumber">校园卡号:{{ user.cardNumber.replace(/^(.{3})(?:\w+)(.{4})$/,
                "\$1*********$2") }}
            </div>
            <div v-if="user.personType === 1 && user.cardNumber">身份证号:{{ user.cardNumber.replace(/^(.{3})(?:\w+)(.{4})$/,
                "\$1*********$2") }}
            </div>
        </template>
    </div>
</template>

<script>
import { getFinduser } from '@/api/index'
export default {
    data() {
        return {
            user: {},
            bookedPerson: ''
        }
    },
    created() {
        this.bookedPerson = localStorage.getItem('uuid')
        this.getFinduserApi()
    },
    methods: {
        //获取头部信息
        async getFinduserApi() {
            let { bookedPerson } = this
            let res = await getFinduser({ bookedPerson })
            if (res.data.code == 200) {
                this.user = res.data.data.data //拿到用户头部登录得信息
                this.$emit('user', this.user)
            } else {
                this.$toast.fail(`${res.data.msg}`)
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.person-xinxi {
    width: 90%;
    margin: auto;
    background-color: #ffffff;
    border-radius: 5px;
    box-shadow: 0 1px 4px 0px rgba(0, 0, 0, 0.2);
    padding: 10px 20px;
    margin: 20px auto 10px auto;
}
</style>